#include "zkthread.h"
#include "message.h"
#include "processhub.h"

namespace ProcessRouter {

ZKThread::ZKThread()
{
    m_zk = new ZooKit(ProcessHub::instance()->info()->configuer()->groupname());
    m_zk->connect(ProcessHub::instance()->info()->configuer()->zookeeperhost());
    m_zk->init(ProcessHub::instance()->info()->ip() + ":" + ProcessHub::instance()->info()->configuer()->socketport());
}

ZKThread::~ZKThread()
{
    m_zk->destroy();
}

void ZKThread::threadMain()
{
    while(!m_stop) {
        m_zk->set(ProcessHub::instance()->info()->serialize());
        usleep(10000);
        //m_zk->setPageInfo(ProcessHub::instance()->serializePageInfo());
    }
}


}
